﻿using System;
class CardWars
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string card;
        bool player1X = false, player2X = false;
        int player1Score = 0, player2Score = 0;
        int player1Total = 0, player2Total = 0;
        long player1Games = 0, player2Games = 0;
        for (int i = 0; i < n; i++)
        {
            player1Score = 0;
            player2Score = 0;
            for (int j = 0; j < 3; j++)
            {
                card = Console.ReadLine();
                switch (card)
                {
                    case "A": player1Score += 1; break;
                    case "K": player1Score += 13; break;
                    case "Q": player1Score += 12; break;
                    case "J": player1Score += 11; break;
                    case "X": player1X = true; break;
                    case "Y": player1Score -= 200; break;
                    case "Z": player1Score *= 2; break;
                    default: player1Score += 12 - int.Parse(card); break;
                }
            }
            for (int j = 0; j < 3; j++)
            {
                card = Console.ReadLine();
                switch (card)
                {
                    case "A": player2Score += 1; break;
                    case "K": player2Score += 13; break;
                    case "Q": player2Score += 12; break;
                    case "J": player2Score += 11; break;
                    case "X": player2X = true; break;
                    case "Y": player2Score -= 200; break;
                    case "Z": player2Score *= 2; break;
                    default: player2Score += 12 - int.Parse(card); break;
                }
            }
            if (player1X && !player2X)
            {
                Console.WriteLine("X card drawn! Player one wins the match!");
                return;
            }
            else if (!player1X && player2X)
            {
                Console.WriteLine("X card drawn! Player two wins the match!");
                return;
            }
            else if (player1X && player2X)
            {
                player1Score += 50;
                player2Score += 50;
            }
            if (player1Score > player2Score)
            {
                player1Total += player1Score;
                player1Games += 1;
            }
            else if (player1Score < player2Score)
            {
                player2Total += player2Score;
                player2Games += 1;
            }
        }
        if (player1Total == player2Total)
        {
            Console.WriteLine("It's a tie!\nScore: {0}", player1Total);
        }
        else if (player1Total > player2Total)
        {
            Console.WriteLine("First player wins!");
            Console.WriteLine("Score: {0}",player1Total);
            Console.WriteLine("Games won: {0}",player1Games);
        }
        else
        {
            Console.WriteLine("Second player wins!");
            Console.WriteLine("Score: {0}", player2Total);
            Console.WriteLine("Games won: {0}", player2Games);
        }
    }
}